<?php

include_once('logic/action/Action.php');
include_once('logic/view/delete_view.php');

class DeleteAction extends Action
{
	public function perform()
	{
		$View = new DeleteView();
		if (Session::getSessionVar ("logged_in") == 'true')
		{
			$View->setParam('_user_logged_in', 'true');

			$photoId = HttpRequest::getRequest("id");
			$View->setParam('_id', $photoId);
			if (HttpRequest::getRequest('form_posted') == 'posted')
			{
				$Photos = new PhotosDAO();
				$Tags   = new TagsDAO();

				$Tags->deleteAllTags($photoId);
				$Photos->deleteEntry($photoId);
				header('Location: index.php?op=manage');
			}
		} else {
			$View->setParam('_user_logged_in', 'false');
		}
		parent::setCommonParams($View);
		$View->Display();
	}
}

?>
